--[[/**
-- * 
 * 控制敌方朝着自身行走
-- *
-- */]]

---@class BuffEffect283100 : BaseBuffEffect
BuffEffect283100 = ClientFight.CreateClass("BuffEffect283100", ClientFight.BaseBuffEffect)
local t = BuffEffect283100

---@param fight Fight
---@param buff FighterBuff
function t:add(fight, buff)
    t:moveTo(fight, buff, buff.getTarget(), buff.getSource());
    return ClientFight.BaseBuffEffect.add(self, fight, buff);
end
function t:moveTo(fight, buff, fighter, to)
    local intervalDistance = toRatio(buff.buffBean.f_BuffEffectValue[1]);
    local targetPosition = t:calculateMovePosition(fighter, to, intervalDistance);
    fighter.movePosition = targetPosition;

    ReportManager.setMoveEndToJsonString(fight, fighter, fighter.moveAction);
    table.insert(fight.actions, clone(fighter.moveAction))
    FightManager.playActions(fighter.moveAction)
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s Buff%s 触发卡洛琳精神控制,朝%s行走,卡洛琳坐标%s",
            fight.frame, buff.target.fighterId, buff.modelId, targetPosition, buff.source.position
    ));
end
--[[
计算跑向位置
]]
function t:calculateMovePosition(fighter, target, intervalDistance)
    local distance = DistanceUtil.countDistance(fighter.position, target.position);
    local scale = 1 - intervalDistance / distance;
    local x = fighter.position.x + (target.position.x - fighter.position.x) * scale;
    local y = fighter.position.y + (target.position.y - fighter.position.y) * scale;

    return Vector2.New(x, y);
end
t.New()